$(function() {
	$('.loginBtn').click(function() {
		var userName = $('#value_1').val();
		var password = $('#value_2').val();
		if (userName=='') {
			alert('请输入用户名');
			return;
		}
		if (password=='') {
			alert('请输入密码');
			return;
		}
		$.post('toLogin.do',{userName:userName,password:password},function(result) {
			if(result.state==0) {
				var user = result.data;
				setCookie('id',user.id);
				setCookie('name',user.name);
				setCookie('userName',user.userName);
				setCookie('lastLogin',user.lastLogin);
				setCookie('token',user.token);
				window.location.href='pageIndex.htm';
			} else {
				alert(result.message);
			}
		})
	})
})